import { Injectable } from '@angular/core';
import { HttpService } from '../../../core/http.service';
import { SERVERS_NAME } from '../../../config/config';

@Injectable()
export class ClassMajorTreeService {
  protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/`;

  constructor(private http: HttpService) {
  }

  /**
   * 查询树
   */
  getTree() {
    return this.http.get({}, `${this.preUrl}college/tree`);
  }

  /**
   * 新增分类
   */
  addNewNode(data) {
    return this.http.post(data, `${this.preUrl}college/create`);
  }

  /**
   * 编辑分类
   */
  editNode(data) {
    return this.http.post(data, `${this.preUrl}college/update`);
  }

  /**
   * 删除分类
   */
  deleteNode(data) {
    return this.http.post(data, `${this.preUrl}college/delete`);
  }

  /**
   * 获取部门和专业的数据结构
   */
  getDeptAndMajorApi(data) {
    return this.http.post(data, `${this.preUrl}dept/treeDeptWithMajor`);
  }
}

export class NewInfos {
  name?: string;
  parentId?: string;
  type?: string;
}
